# -*- coding: utf-8 -*-
from flask import Flask
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
import os


class Application(Flask):
    def __init__(self, import_name, template_folder=None):
        super(Application, self).__init__(import_name, template_folder=template_folder)
        self.config.from_pyfile('config/base_setting.py')
        if "ops_config" in os.environ:
            self.config.from_pyfile('config/%s_setting.py' % os.environ['ops_config'])
            # ops_config是选择local|production中的一个
        else:  # 默认运行用线下模型
            self.config.from_pyfile('config/local_setting.py')

        db.init_app(self)


db = SQLAlchemy()

import os

template_folder = os.getcwd() + "/web/templates/"
print('template_folder:', template_folder)
app = Application(__name__, template_folder=template_folder)
manager = Manager(app)
